<include file="Finance:leftmenu" />
<div class="content-right fl">
	<h1 class="content-right-title">CEO报单</h1>
	
	<form action="" id="form" method="POST">
       
       <div class="formitems">  
			<label class="fi-name"><span class="colorRed">*</span>用户姓名：</label>
			<div class="form-controls">
				<input  type="text" id="realname" class="input large" name="realname" >
			</div>
		</div>
		
		<div class="formitems">  
			<label class="fi-name"><span class="colorRed">*</span>会员手机号：</label>
			<div class="form-controls">
				<input type="text" id="mobileNumber" class="input large" name="mobile" autocomplete="off">
			</div>
			
		</div>
		
		
		<div class="formitems" style="display:none">  
			<label class="fi-name">grade_id：</label>
			<div class="form-controls">
				<input id="grade_id"  type="text" id="grade_id" class="input large" name="grade_id" >
			</div>
		</div>
	
		<div class="formitems is_new_hidden">
	        <label class="fi-name"><span class="colorRed">*</span>推荐人手机/姓名：</label>
	        <div class="form-controls">
	            <input type="text" id="topMobileNumber" class="input large" name="refer_mobile" autocomplete="off">
	            <span class="fi-help-text " style="color:red;">请填写用户的上级用户手机号或姓名</span>
	            <div class="topmatchs fi-help-text" style="width:400px;position:absolute;z-index:999999"></div>
	        </div>
	        
	    </div>
	    
		<div class="formitems is_new_hidden">
	        <label class="fi-name"><span class="colorRed">*</span>推荐人：</label>
	        <div class="form-controls" id="topUser">
	            
	        </div>
	        <span class="fi-help-text" style="color:red;">请仔细核对推荐人是否正确</span>
	    </div>
    
		<div class="formitems">  
			<label class="fi-name"><span class="colorRed">*</span>充值金额：</label>
			<div class="form-controls">
				<input  type="text" id="tihuo_money" class="input large" value="0" name="tihuo_money" >
			</div>
		</div>
		
		<div class="mgl120">
			<a href="javascript:tijiao();" class="btn btn-primary j-add">确认报单升级</a>
		</div>
	</form>
</div>
<script>

function tijiao(){
	var title = "以上数据非常重要,你确定要继续提交新数据吗?";
	
	layer.confirm(title, {
	    btn: ['确定','我再想想'] //按钮
	}, function(){
		AjaxFormSubmit();
	}, function(){
		layer.msg('你取消了提交', {icon: 7});
	});
}



//根据上级推荐人手机号匹配用户
$("#topMobileNumber").keyup(function(){
	var str = $(this).val();
	var self = $(this);
	//输入第三位手机号时开始匹配
	if(str){
		$.ajax({
			url:"/admin/common/matchmember",
			type:"post",
			data:{str:str},
			dataType:"json",
			success:function(data){
				
				console.log(data);
				var dom = $(".topmatchs");
				dom.html("");
				$.each(data,function(){
					//memberAccount = data;
					var html = '<div class="topmatch" data-mobile='+this.mobile+' data-uid='+this.uid+'	data-realname='+(this.realname?this.realname:this.nickname)+' style="padding:5px 20px;background-color:#D3D3D3;border-bottom:2px solid white;" >姓名：'+(this.realname?this.realname:this.nickname)+' 手机号码：'+this.mobile+'</div>';
					dom.append(html);
				});
				$(".topmatch").on("click",function(){
					
					var mobile = $(this).attr('data-mobile');
					var uid = $(this).attr('data-uid');
					var realname = $(this).attr('data-realname');
					self.val(mobile);
					$("#topUser").text("推荐人id："+uid+"推荐人姓名："+realname);
				
					$("#refer_uid").val(uid);
					dom.html("");
				});
			},
			error:function(){
				$(".topmatchs").html("");
				$("#topUser").text("");
				
			}
		});
	}else{
		$(".topmatchs").html("");
		$("#topUser").text("");
		
	}
});

</script>